﻿<%@ Page Language="C#" MasterPageFile="~/Theme/Stander/Stander.master" AutoEventWireup="true" CodeFile="CustomerOrders.aspx.cs" Inherits="Bill_CustomerOrders" %>
<%@ Register Src="../User Controls/OrderStateControl.ascx" TagName="OrderStateControl"
    TagPrefix="uc2" %>
<%@ Register Src="../User Controls/CampaignPeriodControl.ascx" 
    TagName="CampaignPeriodControl" TagPrefix="uc1" %>
<%@ Import Namespace="Active.Core" %>
<asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolder1" Runat="Server">
<uc2:OrderStateControl id="OrderStateControl1" runat="server"></uc2:OrderStateControl>
<asp:MultiView ID="MultiView1" runat="server" ActiveViewIndex="0">
<asp:View ID="MainView" runat="server">
<asp:GridView ID="CustomerOrdersGridView" DataSourceID="CustomerOrdersDataSource" CssClass="normal"
    AutoGenerateColumns="false" ShowFooter="true" OnRowDataBound="CustomerOrdersGridView_RowDataBound"
    runat="server" OnRowCommand="CustomerOrdersGridView_RowCommand">
<Columns>
    <asp:BoundField HeaderText="频道" DataField="Channel" />
    <asp:BoundField HeaderText="单价" DataField="UnitPrice" DataFormatString="{0:f2}" ItemStyle-CssClass="right" />
    <asp:BoundField HeaderText="次数" DataField="Times" />
    <asp:BoundField HeaderText="优惠率" DataField="Discount" DataFormatString="{0:p2}" />
    <asp:BoundField HeaderText="应付" DataField="Payout" DataFormatString="{0:f2}" ItemStyle-CssClass="right" />
    <asp:BoundField HeaderText="实际优惠率" DataField="RealDiscount" DataFormatString="{0:p2}" />
    <asp:BoundField HeaderText="实付" DataField="RealPayout" DataFormatString="{0:f2}" ItemStyle-CssClass="right" />
    <asp:TemplateField>
        <ItemTemplate>
            <asp:LinkButton ID="lbtnEditCustOrder" CommandName="Edit" 
                CommandArgument='<%# Eval("Id") %>' runat="server">编辑</asp:LinkButton>
        </ItemTemplate>
    </asp:TemplateField>
    <asp:TemplateField>
        <ItemTemplate>
            <asp:LinkButton ID="lbtnDeleteCustOrder" CommandName="Delete" 
                CommandArgument='<%# Eval("Id") %>' OnClientClick="return deleteConfirm(event);" 
                runat="server">删除</asp:LinkButton>
        </ItemTemplate>
    </asp:TemplateField>
</Columns>
</asp:GridView>
<csla:CslaDataSource ID="CustomerOrdersDataSource" runat="server" 
    TypeName="Active.Core.CustomerOrders, Active.Core"
    TypeSupportsPaging="False" TypeSupportsSorting="False" 
    OnSelectObject="CustomerOrdersDataSource_SelectObject">
</csla:CslaDataSource>
<p><asp:LinkButton ID="lbtnAddCustomerOrder" runat="server" OnClick="lbtnAddCustomerOrder_Click">添加客户订单</asp:LinkButton></p>
<h2>备注</h2>
<p>
    <asp:TextBox ID="txtDescription" TextMode="MultiLine" Rows="5" runat="server"></asp:TextBox>
</p>
<p><asp:Button ID="btnSaveOrder" OnClick="btnSaveOrder_Click" runat="server" Text="保存" /></p>
</asp:View>
<asp:View ID="EditCustomerOrderView" runat="server">
<h2>填写客户订单</h2>
<asp:UpdatePanel ID="UpdatePanel1" runat="server">
<ContentTemplate>
<asp:DetailsView ID="CustomerOrderDetailsView" runat="server" DataSourceID="CustomerOrderDataSource"
    AutoGenerateRows="False"
    OnItemCommand="CustomerOrderDetailsView_ItemCommand" 
    OnDataBound="CustomerOrderDetailsView_DataBound" DataKeyNames="Id">
<Fields>
    <asp:TemplateField HeaderText="订单类型:">
        <InsertItemTemplate>
            <asp:DropDownList ID="ddlOrderType" runat="server" SelectedValue='<%# Bind("Category") %>'>
                <asp:ListItem Text="输入单价" Value="Pay"></asp:ListItem>
                <asp:ListItem Text="套播" Value="Series"></asp:ListItem>
                <asp:ListItem Text="赠送" Value="Present"></asp:ListItem>
                <asp:ListItem Text="追加款" Value="Additional"></asp:ListItem>
            </asp:DropDownList>
        </InsertItemTemplate>
        <EditItemTemplate>
            <asp:DropDownList ID="ddlOrderType" runat="server" SelectedValue='<%# Bind("Category") %>'>
                <asp:ListItem Text="输入单价" Value="Pay"></asp:ListItem>
                <asp:ListItem Text="套播" Value="Series"></asp:ListItem>
                <asp:ListItem Text="赠送" Value="Present"></asp:ListItem>
                <asp:ListItem Text="追加款" Value="Additional"></asp:ListItem>
            </asp:DropDownList>
        </EditItemTemplate>
    </asp:TemplateField>
    <asp:TemplateField HeaderText="频道:" >
        <InsertItemTemplate>
            <asp:DropDownList ID="ddlChannels" DataSource='<%# GetOrder().Media.ChannelsArray %>' 
                runat="server" SelectedValue='<%# Bind("Channel") %>'>
            </asp:DropDownList>
        </InsertItemTemplate>
        <EditItemTemplate>
            <asp:DropDownList ID="ddlChannels" DataSource='<%# GetOrder().Media.ChannelsArray %>' 
                runat="server" SelectedValue='<%# Bind("Channel") %>'>
            </asp:DropDownList>
        </EditItemTemplate>
    </asp:TemplateField>
    <asp:TemplateField HeaderText="单价:">
        <InsertItemTemplate>
            <asp:TextBox ID="txtUnitPrice" Text='<%# Bind("UnitPrice") %>'
                CssClass="short" runat="server">0</asp:TextBox>
            <asp:RequiredFieldValidator ID="RequiredFieldValidator1" ControlToValidate="txtUnitPrice"
                    runat="server" ErrorMessage="*"></asp:RequiredFieldValidator>
        </InsertItemTemplate>
        <EditItemTemplate>
            <asp:TextBox ID="txtUnitPrice" Text='<%# Bind("UnitPrice", "{0:f2}") %>'
                CssClass="short" runat="server">0</asp:TextBox>
            <asp:RequiredFieldValidator ID="RequiredFieldValidator1" ControlToValidate="txtUnitPrice"
                    runat="server" ErrorMessage="*"></asp:RequiredFieldValidator>
        </EditItemTemplate>
    </asp:TemplateField>
    <asp:TemplateField HeaderText="次数:">
        <InsertItemTemplate>
            <asp:TextBox ID="txtTimes" Text='<%# Bind("Times") %>' CssClass="short" runat="server">0</asp:TextBox>
        </InsertItemTemplate>
        <EditItemTemplate>
            <asp:TextBox ID="txtTimes" Text='<%# Bind("Times") %>' CssClass="short" runat="server">0</asp:TextBox>
        </EditItemTemplate>
    </asp:TemplateField>
    <asp:TemplateField HeaderText="优惠率:">
        <InsertItemTemplate>
            <asp:TextBox ID="txtDiscount" Text='<%# Bind("Discount", "{0:p2}") %>' 
                CssClass="short" runat="server">0</asp:TextBox>%
            <asp:RequiredFieldValidator ID="RequiredFieldValidatortxtDiscount" ControlToValidate="txtDiscount"
                    runat="server" ErrorMessage="*"></asp:RequiredFieldValidator>
        </InsertItemTemplate>
        <EditItemTemplate>
            <asp:TextBox ID="txtDiscount" Text='<%# Bind("Discount", "{0:p2}") %>' 
                CssClass="short" runat="server">0</asp:TextBox>%
            <asp:RequiredFieldValidator ID="RequiredFieldValidatortxtDiscount" ControlToValidate="txtDiscount"
                    runat="server" ErrorMessage="*"></asp:RequiredFieldValidator>
        </EditItemTemplate>
    </asp:TemplateField>
    <asp:TemplateField HeaderText="实际优惠率:">
        <InsertItemTemplate>
            <asp:TextBox ID="txtRealDiscount" Text='<%# Bind("RealDiscount", "{0:p2}") %>' 
                CssClass="short" runat="server">0</asp:TextBox>%
            <asp:RequiredFieldValidator ID="RequiredFieldValidatortxtRealDiscount" 
                ControlToValidate="txtRealDiscount"
                runat="server" ErrorMessage="*"></asp:RequiredFieldValidator>
        </InsertItemTemplate>
        <EditItemTemplate>
            <asp:TextBox ID="txtRealDiscount" Text='<%# Bind("RealDiscount", "{0:p2}") %>' 
                CssClass="short" runat="server">0</asp:TextBox>%
            <asp:RequiredFieldValidator ID="RequiredFieldValidatortxtRealDiscount" 
                ControlToValidate="txtRealDiscount"
                runat="server" ErrorMessage="*"></asp:RequiredFieldValidator>
        </EditItemTemplate>
    </asp:TemplateField>
    <asp:CommandField ShowInsertButton="True" ShowEditButton="True" InsertText="添加"
        EditText="更新" CancelText="返 回" ButtonType="Button" />
</Fields>
</asp:DetailsView>
</ContentTemplate>
</asp:UpdatePanel>
<csla:CslaDataSource ID="CustomerOrderDataSource" runat="server" 
    TypeName="Active.Core.CustomerOrder, Active.Core"
    TypeSupportsPaging="False" TypeSupportsSorting="False" 
    OnSelectObject="CustomerOrderDataSource_SelectObject" 
    OnInsertObject="CustomerOrderDataSource_InsertObject" 
    OnUpdateObject="CustomerOrderDataSource_UpdateObject">
</csla:CslaDataSource>
</asp:View>
</asp:MultiView>
</asp:Content>

